<%@ page import="org.springframework.web.context.WebApplicationContext" %>
<%@ page import="com.mg.service.ContractService" %>
<%@ page import="com.mg.dto.ContractDto" %>
<%@ page import="com.github.pagehelper.PageInfo" %>
<%@ page import="java.util.List" %>
<%@ page import="com.mg.service.DataCodeService" %>
<%@ page import="com.mg.dto.DataCodeDto" %>
<%@ page import="com.mg.model.DataCode" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ include file="../../common/taglibs.jsp" %>
<%@ include file="../../common/session.script.inc.jsp" %>
<%
    WebApplicationContext context = (WebApplicationContext) request.getServletContext().getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
    ContractService contractService = (ContractService) context.getBean("contractServiceImpl");
    DataCodeService dataCodeService = (DataCodeService) context.getBean("dataCodeServiceImpl");
    ContractDto contractDto = new ContractDto();
    PageInfo<ContractDto> pageInfo = contractService.selectPageInfo(contractDto, 0, 3);
    List<ContractDto> contractDtoList = pageInfo.getList();
    // 将查询出来的用户信息保存到session对象中
    session.setAttribute("contractDtoList", contractDtoList);
    DataCode dataCode = new DataCode();
    dataCode.setOriCategoryId("1001");
    List<DataCode> dataCodes = dataCodeService.select(dataCode);
    Map<String,String>  dataMap = new HashMap<>();
    for(DataCode dataCode1:dataCodes){
        dataMap.put(dataCode1.getOriCodeId(),dataCode1.getOriCodeValue());
    }

%>
<html>
<head>
    <title>首页</title>

    <link rel="stylesheet" type="text/css" href="${ctx}/pages/home/css/home.css">
    <link rel="stylesheet" href="${ctx}/public/bootstrap/css/bootstrap.min.css">
    <script type="text/javascript" src="${ctx}/public/jQuery/js/jquery.min.js"></script>
    <script type="text/javascript" src="${ctx}/public/bootstrap/js/bootstrap.min.js"></script>
</head>

<style>
    .glyphicon-eth:before {
        content: "E";
        position: relative;
        top: 1px;
        display: inline-block;
        font-family: 'Glyphicons Halflings';
        font-style: normal;
        font-weight: normal;
        line-height: 1;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
</style>
<body>
<div class="row-banner"></div>
<div class="container row-power">
    <div class="power-top">
        <h4>过去24小时算力数据表</h4>
        <h6>我们的算力收益相比于全网算力收益更具性价比</h6>
    </div>
    <div class="row">
        <ul>
            <li><span class="glyphicon glyphicon-eth" style="font-size: 60px; color: #1E9FFF;"></span>
                <div>100M算力昨日出币数</div>
                <p class="power-p"><%=dataMap.get("ethNum")%></p>
            </li>
            <li><span class="glyphicon glyphicon-piggy-bank" style="font-size: 60px; color: #1E9FFF;"></span>
                <div>100M算力昨日收益</div>
                <p class="power-p"><%=dataMap.get("revenue")%></p>
            </li>
            <li><span class="glyphicon glyphicon-yen" style="font-size: 60px; color: #1E9FFF;"></span>
                <div>昨日ETH价格</div>
                <p class="power-p"><%=dataMap.get("ethPrice")%></p>
            </li>
            <li><span class="glyphicon glyphicon-globe" style="font-size: 60px; color: #1E9FFF;"></span>
                <div>矿池整体幸运度</div>
                <p class="power-p"><%=dataMap.get("luckyDegree")%></p>
            </li>
            <li><span class="glyphicon glyphicon-time" style="font-size: 60px; color: #1E9FFF;"></span>
                <div>平均难度</div>
                <p class="power-p"><%=dataMap.get("avgDifficulty")%></p>
            </li>
            <li><span class="glyphicon glyphicon-euro" style="font-size: 60px; color: #1E9FFF;"></span>
                <div>平均算力</div>
                <p class="power-p"><%=dataMap.get("avgPower")%></p>
            </li>
        </ul>
    </div>
</div>
<div class="container contract">
    <div class="row">
        <div class="contract_top">
            <h4>共享挖矿合约</h4>
            <h6>合约品种齐全，现货期货可选</h6>
        </div>
        <ul>
            <c:forEach items="${sessionScope.contractDtoList}" var="contract">
                <li>
                    <div class="contract-left"><span
                            class="contract-left-text">${contract.content}</span><img
                            src="./images/machineType${contract.machineTypeId}.jpg" alt=""></div>
                    <div class="contract-right">
                        <h5>${contract.contractName}</h5>
                        <table cellspacing="0" cellpadding="0">
                            <tbody>
                            <tr>
                                <td>${contract.price}元<p>售价</p></td>
                                <td>${contract.computingPower}Mb/s<p>合约单位</p></td>
                                <td>${contract.electricityFee}元/天<p>电费</p></td>
                            </tr>
                            <tr class="nobb">
                                <td>${contract.managementCost} %<p>交易手续及管理费</p></td>
                                <td>${contract.total} <p>发行总量</p></td>
                                <td>${contract.stock} <p>库存</p></td>
                            </tr>
                            </tbody>
                        </table>
                        <c:if test="${contract.stock<1.00}">
                            <a class="buyit" style="background:#7B7C7D;color: #fff " disabled="true">已售罄</a>
                        </c:if>
                        <c:if test="${contract.stock>0.00}">
                            <a href="#" contractId="${contract.id}" class="buy" style="background:#eb8016;color: #fff ">购买</a>
                        </c:if>
                    </div>
                </li>
            </c:forEach>
        </ul>
    </div>
</div>
<div class="bg-flow-img">
    <div class="flow container">
        <h4>购买流程</h4>
        <div class="step">
            <div>
                <p><img src="./images/step01.png"><br>
                    注册账户</p>
            </div>
            <div>
                <p><img src="./images/step02.png"><br>
                    账户充值</p>
            </div>
            <div>
                <p><img src="./images/step03.png"><br>
                    确认下单</p>
            </div>
            <div>
                <p><img src="./images/step04.png"><br>
                    开始挖矿</p>
            </div>
            <div>
                <p><img src="./images/step05.png"><br>
                    获得收益 </p>
            </div>
        </div>
    </div>
</div>
<div class="container mine">
    <div class="row">
        <div class="mine-top">
            <h4>矿场一览</h4>
            <h6>从矿机选购到产生收益，严格控制每个业务流程，从而全面把控生命周期</h6>
        </div>
        <ul class="mine-bottom">
            <li class="mine-bottom-li">
                <div class="mine-bottom-img"> <img src="./images/mine_1.jpg"> </div>
            </li>
            <li class="mine-bottom-li">
                <div class="mine-bottom-img"> <img src="./images/mine_2.jpg"> </div>
            </li>
            <li class="mine-bottom-li">
                <div class="mine-bottom-img"> <img src="./images/mine_3.jpg"> </div>
            </li>
            <li class="mine-bottom-li">
                <div class="mine-bottom-img"> <img src="./images/mine_4.jpg"> </div>
            </li>
            <li class="mine-bottom-li">
                <div class="mine-bottom-img"> <img src="./images/mine_5.jpg"> </div>
            </li>
            <li class="mine-bottom-li">
                <div class="mine-bottom-img"> <img src="./images/mine_6.jpg"> </div>
            </li>
        </ul>
    </div>
</div>
<div class="container service">
    <div class="row">
        <div class="service_content">
            <h4>服务优势</h4>
            <h6>共享挖矿相比于自己挖矿更具性价比</h6>
        </div>
        <ul>
            <li>
                <div><img src="images/service1.png"> </div>
                <div>真实挖矿</div>
                <p>算力合约即买即挖，无需等待</p>
                <p>摆脱噪音、电量、维护的烦恼</p>
            </li>
            <li>
                <div><img src="images/service2.png"> </div>
                <div>稳定可靠</div>
                <p>专业化部署，99.9%无故障保证</p>
                <p>每日收益明细一目了然</p>
            </li>
            <li>
                <div><img src="images/service3.png"></div>
                <div>灵活投资</div>
                <p>算力品种齐全，现货期货可选</p>
                <p>最低10M算力就可以体验挖矿</p>
            </li>
        </ul>
    </div>
</div>
<%--<%@ include file="../../common/head.builive.inc.jsp" %>--%>
</body>
<script type="text/javascript">
    var ctx = "${ctx}";
    var webRoot=ctx+"/";

</script>
<script type="text/javascript" src="${ctx}/pages/home/js/home.js"></script>
</html>